<?php

namespace App\Models\OpenShop\InvestmentPromotion;

use App\Enums\BaseErrorCode;
use App\Enums\OpenShop\InvestmentPromotion\ErrCode;
use App\Enums\OpenShop\InvestmentPromotion\OrganizationManageEnum;
use App\Enums\OpenShop\InvestmentPromotion\SignOrderEnum;
use App\Exceptions\Custom\CustomHttpResponseException;
use App\Exceptions\Custom\ResponseHttpException;
use App\Models\BaseModel;
use App\Models\Traits\KfUid;
use App\Service\OpenShop\Feishu\OrganizationManageService;
use App\Service\OpenShop\Feishu\PermissionService;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use function Symfony\Component\String\s;

class OpenShopSignOrderPermissionAnchorModel extends BaseModel
{
    use KfUid;

    protected $table = 'open_shop_sign_order_permission_anchor';

    protected $fillable = [
        'orderNo',
        'provinceCode',
        'cityCode',
        'districtCode',
        'signInvestmentManagerId',
        'localInvestmentManagerId',
        'designUid',
        'preparationUid',
        'checkManagerId',
        'missionHandler',
        'orderStatus',
    ];

    public function getProvinceInfo()
    {
        $provinceManager = OrganizationManageService::getProvinceInfoByProvinceCode($this->provinceCode);
        $operationUid    = $provinceManager["operationUid"] ?? 0;
        $operationName   = $provinceManager["operationName"] ?? '';

        return [
            'operationUid'  => $operationUid,
            'operationName' => $operationName
        ];
    }


}
